package com.lxw.manage_cms.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.HashSet;
import java.util.TreeSet;


@Configuration
public class MqConfig {
    //queue
    @Bean
    public Queue queue() {
        return new Queue(MqConst.TEST_MQ, false, false, false, null);
    }

    @Bean
    public Queue queue2() {
        return new Queue(MqConst.TEST_MQ_2, false, false, false, null);
    }

    //路由
    @Bean
    public DirectExchange exchange() {
        return new DirectExchange(MqConst.EXCHANGE_TEST);

    }

    @Bean
    public FanoutExchange fanoutExchange() {
        return new FanoutExchange(MqConst.EXCHANGE_TEST_FanoutExchange);

    }

    //将消息对列和路由绑定
    @Bean
    public Binding bindTestMqToDirect() {
        return BindingBuilder.bind(queue()).to(exchange()).with(MqConst.TEST_MQ);

    }

    @Bean
    public Binding queueBindexchange() {
        return BindingBuilder.bind(queue()).to(fanoutExchange());

    }

    @Bean
    public Binding queue2Bindexchange() {
        return BindingBuilder.bind(queue2()).to(fanoutExchange());

    }
}
